import React, { Component } from "react";
import Child11 from "../component/Child11";
import  UserModel from  "../model/userModel";

export default class Life extends Component {
  constructor(props) {
    super(props);
    this.state = {
      num: 100,
    };
    console.log("1");
  }
  render() {
    console.log("2");
    return <div>生命周期
        <button onClick={()=>{
            this.setState({
                num:this.state.num+1
            })
        }}>修改数据</button>
        <br/>
        <Child11 num={this.state.num}></Child11>
    </div>;
  }

  async componentDidMount() {
      console.log("3")
    //组件初步挂载完成  里面可以进行数据请求
    setTimeout(() => {
        this.setState({
            num:999
        })

    }, 2000);
    let  {data} = await  UserModel.query({});
    console.log(data);



  }
  componentDidUpdate(){
      console.log("4");
  }
  componentWillUnmount(){
      console.log("5")
  }
}
